/*
 * Created by JFormDesigner on Sat May 25 23:20:07 CST 2024
 */

package view.user;

import model.user.User;

import java.awt.event.*;


import java.awt.*;
import javax.swing.*;

/**
 * 个人信息面板
 */
public class PersonalInformationPanel extends JPanel {
    private Mainframe frame;
    private User user;
    public PersonalInformationPanel(Mainframe frame,User user) {
        initComponents();
        this.frame = frame;
        this.user = user;
        nameText.setText(user.getName());
        IDtext.setText(user.getIDNumber());
        phoneText.setText(user.getContactInformation());
        vipText.setText(user.getMembership());
        passwordText.setText(user.getPassword());
    }

    private void edit(ActionEvent e) {
        // TODO add your code here
        frame.showEditPanel();
    }

    private void flush(ActionEvent e) {
        // TODO add your code here
        nameText.setText(user.getName());
        IDtext.setText(user.getIDNumber());
        phoneText.setText(user.getContactInformation());
        vipText.setText(user.getMembership());
        passwordText.setText(user.getPassword());
    }

    private void initComponents() {
        // JFormDesigner - Component initialization - DO NOT MODIFY  //GEN-BEGIN:initComponents  @formatter:off
        // Generated using JFormDesigner Evaluation license - 马世鹏
        panel1 = new JPanel();
        panel2 = new JPanel();
        label5 = new JLabel();
        label6 = new JLabel();
        label7 = new JLabel();
        label8 = new JLabel();
        label9 = new JLabel();
        nameText = new JLabel();
        IDtext = new JLabel();
        phoneText = new JLabel();
        vipText = new JLabel();
        passwordText = new JLabel();
        editButton = new JButton();
        flushButton = new JButton();

        //======== this ========
        setBorder (new javax. swing. border. CompoundBorder( new javax .swing .border .TitledBorder (new javax. swing. border
        . EmptyBorder( 0, 0, 0, 0) , "JF\u006frmDesi\u0067ner Ev\u0061luatio\u006e", javax. swing. border. TitledBorder. CENTER, javax
        . swing. border. TitledBorder. BOTTOM, new java .awt .Font ("Dialo\u0067" ,java .awt .Font .BOLD ,
        12 ), java. awt. Color. red) , getBorder( )) );  addPropertyChangeListener (new java. beans
        . PropertyChangeListener( ){ @Override public void propertyChange (java .beans .PropertyChangeEvent e) {if ("borde\u0072" .equals (e .
        getPropertyName () )) throw new RuntimeException( ); }} );

        //======== panel1 ========
        {
            panel1.setLayout(new CardLayout());

            //======== panel2 ========
            {

                //---- label5 ----
                label5.setText("\u59d3\u540d\uff1a");

                //---- label6 ----
                label6.setText("\u8eab\u4efd\u8bc1\u53f7\uff1a");

                //---- label7 ----
                label7.setText("\u7535\u8bdd\u53f7\u7801\uff1a");

                //---- label8 ----
                label8.setText("\u4f1a\u5458\u7b49\u7ea7\uff1a");

                //---- label9 ----
                label9.setText("\u5bc6\u7801\uff1a");

                //---- nameText ----
                nameText.setText("text");

                //---- IDtext ----
                IDtext.setText("text");

                //---- phoneText ----
                phoneText.setText("text");

                //---- vipText ----
                vipText.setText("text");

                //---- passwordText ----
                passwordText.setText("text");

                //---- editButton ----
                editButton.setText("\u4fee\u6539");
                editButton.addActionListener(e -> edit(e));

                //---- flushButton ----
                flushButton.setText("\u5237\u65b0\u4fe1\u606f");
                flushButton.addActionListener(e -> flush(e));

                GroupLayout panel2Layout = new GroupLayout(panel2);
                panel2.setLayout(panel2Layout);
                panel2Layout.setHorizontalGroup(
                    panel2Layout.createParallelGroup()
                        .addGroup(panel2Layout.createSequentialGroup()
                            .addGroup(panel2Layout.createParallelGroup()
                                .addGroup(panel2Layout.createSequentialGroup()
                                    .addGap(213, 213, 213)
                                    .addComponent(label5))
                                .addComponent(label6, GroupLayout.Alignment.TRAILING)
                                .addComponent(label7, GroupLayout.Alignment.TRAILING)
                                .addComponent(label8, GroupLayout.Alignment.TRAILING)
                                .addComponent(label9, GroupLayout.Alignment.TRAILING))
                            .addGap(18, 18, 18)
                            .addGroup(panel2Layout.createParallelGroup()
                                .addComponent(nameText)
                                .addComponent(phoneText)
                                .addComponent(IDtext)
                                .addComponent(vipText)
                                .addComponent(passwordText))
                            .addContainerGap(210, Short.MAX_VALUE))
                        .addGroup(GroupLayout.Alignment.TRAILING, panel2Layout.createSequentialGroup()
                            .addGap(0, 110, Short.MAX_VALUE)
                            .addComponent(flushButton)
                            .addGap(51, 51, 51)
                            .addComponent(editButton)
                            .addGap(179, 179, 179))
                );
                panel2Layout.setVerticalGroup(
                    panel2Layout.createParallelGroup()
                        .addGroup(panel2Layout.createSequentialGroup()
                            .addGap(33, 33, 33)
                            .addGroup(panel2Layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                                .addComponent(label5)
                                .addComponent(nameText))
                            .addGap(12, 12, 12)
                            .addGroup(panel2Layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                                .addComponent(label6)
                                .addComponent(IDtext))
                            .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
                            .addGroup(panel2Layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                                .addComponent(label7)
                                .addComponent(phoneText))
                            .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
                            .addGroup(panel2Layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                                .addComponent(label8)
                                .addComponent(vipText))
                            .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
                            .addGroup(panel2Layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                                .addComponent(label9)
                                .addComponent(passwordText))
                            .addGap(33, 33, 33)
                            .addGroup(panel2Layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                                .addComponent(flushButton)
                                .addComponent(editButton))
                            .addContainerGap(94, Short.MAX_VALUE))
                );
            }
            panel1.add(panel2, "card1");
        }

        GroupLayout layout = new GroupLayout(this);
        setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup()
                .addGroup(layout.createSequentialGroup()
                    .addContainerGap()
                    .addComponent(panel1, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup()
                .addGroup(GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                    .addContainerGap()
                    .addComponent(panel1, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addContainerGap())
        );
        // JFormDesigner - End of component initialization  //GEN-END:initComponents  @formatter:on
    }

    // JFormDesigner - Variables declaration - DO NOT MODIFY  //GEN-BEGIN:variables  @formatter:off
    // Generated using JFormDesigner Evaluation license - 马世鹏
    private JPanel panel1;
    private JPanel panel2;
    private JLabel label5;
    private JLabel label6;
    private JLabel label7;
    private JLabel label8;
    private JLabel label9;
    private JLabel nameText;
    private JLabel IDtext;
    private JLabel phoneText;
    private JLabel vipText;
    private JLabel passwordText;
    private JButton editButton;
    private JButton flushButton;
    // JFormDesigner - End of variables declaration  //GEN-END:variables  @formatter:on


}
